/*
 * Copyright (c) 2012-2014, EpicSaaS Yuan Xin technology Co., Ltd.
 * 
 * All rights reserved.
 */
package com.server.modules.sys.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class BatchNoUtil {

    //业务ID生成方法
    public static String creatbussNo(String bussType, String index) {
        StringBuffer bussId = new StringBuffer();
        switch (bussType) {
            //导入客户业务
            case "1":
                bussId.append("CI");
                break;
            
        }
        Date date = new Date();
        //每日检查更新
        DateFormat myformat = new SimpleDateFormat("yyMMdd");
        String DateStr = myformat.format(date);
        bussId.append(DateStr);
        bussId.append(getBussNo(index));
        return bussId.toString();
    }

    public static String getBussNo(String index) {
        //synchronized(BUSS_INDEX){
        StringBuffer s = new StringBuffer();
        for (int m = 1; m <= 5 - index.length(); m++) {
            s.append("0");
        }
        s.append(index);
        return s.toString();
    }

    //删除昨天生成的业务id
    public static boolean dateCompare(Date date) {
        DateFormat myformat = new SimpleDateFormat("yyyyMMdd");
        String getdateStr = myformat.format(date);
        String dateStr = myformat.format(new Date());
        if (Integer.valueOf(getdateStr).equals(Integer.valueOf(dateStr))) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
    	System.out.println(BatchNoUtil.creatbussNo("1","5"));;
    }
}
